package ru.spbau.bytecode.graph;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.LinkedList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;


public class CompositeVertexTest {

	private final CompositeVertex v = new CompositeVertex("v");
	private final List<Vertex> innerVertices = new LinkedList<Vertex>();
	private static final int INNER_VERTICES_NUMBER = 10;

	@Before
	public void setUp() {
		for (int i = 0; i < INNER_VERTICES_NUMBER; i++) {
			Vertex u = new Vertex(Integer.toString(i));
			v.addInnerVertex(u);
			innerVertices.add(u);
		}
	}
	
	@Test(expected = IllegalStateException.class)
	public void testAddInnerVertex() {
		v.addInnerVertex(v);
	}
	
	@Test
	public void containsInnerVertex() {
		for (Vertex u: innerVertices) {
			assertTrue(v.containsInnerVertex(u));
		}
	}
	
	@Test
	public void getInnerVertices() {
		assertEquals(innerVertices, v.getInnerVertices());
	}
	

	@Test
	public void move() {
		
	}

	@Test
	public void setCatched() {
		v.setCatched(true);
		assertTrue(v.isCatched());
		for (Vertex u: v.getInnerVertices()) {
			assertTrue(u.isCatched());
		}
	}
	
	@Test
	public void invert() {
		v.invert();
		for (Vertex u: v.getInnerVertices()) {
			assertEquals(v.isVisible(), u.isVisible());
		}
	}
}
